package com.qch.demo_01;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * @Author qch
 * @Date 2021/8/3
 */
public class CompletableFutureDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture future = new CompletableFuture();
        new Thread(){
            @Override
            public void run() {
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                future.complete("dssd");
            }
        }.start();
        System.out.println("任务已经提交");
       // future.complete("dd");
        String o =(String) future.get();
        System.out.println(o);

    }
}
